class Lodger:
	def __init__(self, storage, io):
		self.storage = storage
		self.io = io

	def load(self):
		self.storage.load()

	def store(self):
		self.storage.store()

	def clean(self):
		self.storage.clean()
		return self.io().defaultOutput(self)

	def output(self):
		return self.io().output(self.storage.getItems())

	def getItem(self, id):
		return self.io().outputItem(self.storage.getItem(id))

	def editItem(self, id):
		return self.io().editItem(self.storage.getItem(id))
		
	def processItem(self, id=None):
		if id == None:
			id = int(self.io().inputField("id", title="ID"))#id = int(self.io().inputField("id", title="ID"))
		item = self.storage.getItem(id)
		if item:
			item.input(self.io())
			self.storage.addItem(item)
		return self.io().defaultOutput(self)

	def deleteItem(self, id=None):
		if id == None:
			id = int(self.io().inputField("id", title="ID"))#id = int(self.io().inputField("id", title="ID"))
		self.storage.deleteItem(id)
		return self.io().defaultOutput(self)

